
/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package Apusic.impl;

import Apusic.ApusicPackage;
import Apusic.DataSource;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import javax.management.ObjectName;
import org.eclipse.emf.ecore.EObject;
import com.apusic.admin.config.*;
import com.apusic.admin.*;

import cn.edu.pku.sei.ra.wrapping.CommonWrapping.WrappingEObject;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.impl.WrappingEObjectImpl;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectContainmentEListForWrapping;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectResolvingEListForWrapping;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.ImagePool;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Source</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link Apusic.impl.DataSourceImpl#getName <em>Name</em>}</li>
 *   <li>{@link Apusic.impl.DataSourceImpl#getConnectionUrl <em>Connection Url</em>}</li>
 *   <li>{@link Apusic.impl.DataSourceImpl#getDriverClassPath <em>Driver Class Path</em>}</li>
 *   <li>{@link Apusic.impl.DataSourceImpl#getHost <em>Host</em>}</li>
 *   <li>{@link Apusic.impl.DataSourceImpl#getPort <em>Port</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataSourceImpl extends WrappingEObjectImpl implements DataSource
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The default value of the '{@link #getConnectionUrl() <em>Connection Url</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getConnectionUrl()
   * @generated
   * @ordered
   */
  protected static final String CONNECTION_URL_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getConnectionUrl() <em>Connection Url</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getConnectionUrl()
   * @generated
   * @ordered
   */
  protected String connectionUrl = CONNECTION_URL_EDEFAULT;

  /**
   * The default value of the '{@link #getDriverClassPath() <em>Driver Class Path</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDriverClassPath()
   * @generated
   * @ordered
   */
  protected static final String DRIVER_CLASS_PATH_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDriverClassPath() <em>Driver Class Path</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDriverClassPath()
   * @generated
   * @ordered
   */
  protected String driverClassPath = DRIVER_CLASS_PATH_EDEFAULT;

  /**
   * The default value of the '{@link #getHost() <em>Host</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHost()
   * @generated
   * @ordered
   */
  protected static final String HOST_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getHost() <em>Host</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHost()
   * @generated
   * @ordered
   */
  protected String host = HOST_EDEFAULT;

  /**
   * The default value of the '{@link #getPort() <em>Port</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPort()
   * @generated
   * @ordered
   */
  protected static final int PORT_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getPort() <em>Port</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPort()
   * @generated
   * @ordered
   */
  protected int port = PORT_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DataSourceImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ApusicPackage.Literals.DATA_SOURCE;
  }

  
  

  
  
  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
   public boolean isForCore(Object arg0){
   	boolean result=true;
   	if(core==null) return false;
    try{
    if(core!=null && ((DataSourceConfig)core).getName().equals(((DataSourceConfig)arg0).getName()))
  result=true;
else
  result=false;
    }
    catch(Exception e){
      result=false;
    }
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
  public List listSubCores(int featureID){
    List result=new ArrayList();
  
    DataSourceConfig core=(DataSourceConfig)this.getCore();
    if(core==null) 
      return result;
    switch(featureID){
    
  
  
  
  
  
  }
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
  public EClass getChildClassMap(Object object){
    ApusicPackage pack=ApusicPackage.eINSTANCE;	
  
  
  
  
  
  
    return null;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
        Object result=null;
        DataSourceConfig core=(DataSourceConfig)getCore();
        if(core==null) return name;	
        try
{
name=core.getName();
}
catch(Exception e)
{
  name = null;
}
    return name; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
        	
      DataSourceConfig core=(DataSourceConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.DATA_SOURCE__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getConnectionUrl()
  {
        Object result=null;
        DataSourceConfig core=(DataSourceConfig)getCore();
        if(core==null) return connectionUrl;	
        try
{
connectionUrl=core.getConnectionURL();
}
catch(Exception e)
{
  connectionUrl = null;
}
    return connectionUrl; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setConnectionUrl(String newConnectionUrl)
  {
    String oldConnectionUrl = connectionUrl;
    connectionUrl = newConnectionUrl;
        	
      DataSourceConfig core=(DataSourceConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.DATA_SOURCE__CONNECTION_URL, oldConnectionUrl, connectionUrl));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDriverClassPath()
  {
        Object result=null;
        DataSourceConfig core=(DataSourceConfig)getCore();
        if(core==null) return driverClassPath;	
        try
{
driverClassPath=core.getDriverClassPath();
}
catch(Exception e)
{
  driverClassPath = null;
}
    return driverClassPath; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDriverClassPath(String newDriverClassPath)
  {
    String oldDriverClassPath = driverClassPath;
    driverClassPath = newDriverClassPath;
        	
      DataSourceConfig core=(DataSourceConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.DATA_SOURCE__DRIVER_CLASS_PATH, oldDriverClassPath, driverClassPath));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getHost()
  {
        Object result=null;
        DataSourceConfig core=(DataSourceConfig)getCore();
        if(core==null) return host;	
        try
{
host=core.getHost();
}
catch(Exception e)
{
  host = null;
}
    return host; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHost(String newHost)
  {
    String oldHost = host;
    host = newHost;
        	
      DataSourceConfig core=(DataSourceConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.DATA_SOURCE__HOST, oldHost, host));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getPort()
  {
        Object result=null;
        DataSourceConfig core=(DataSourceConfig)getCore();
        if(core==null) return port;	
        try
{
port=core.getPort();
}
catch(Exception e)
{
  port = -1;
}
    return port; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPort(int newPort)
  {
    int oldPort = port;
    port = newPort;
        	
      DataSourceConfig core=(DataSourceConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.DATA_SOURCE__PORT, oldPort, port));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ApusicPackage.DATA_SOURCE__NAME:
        return getName();
      case ApusicPackage.DATA_SOURCE__CONNECTION_URL:
        return getConnectionUrl();
      case ApusicPackage.DATA_SOURCE__DRIVER_CLASS_PATH:
        return getDriverClassPath();
      case ApusicPackage.DATA_SOURCE__HOST:
        return getHost();
      case ApusicPackage.DATA_SOURCE__PORT:
        return new Integer(getPort());
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ApusicPackage.DATA_SOURCE__NAME:
        setName((String)newValue);
        return;
      case ApusicPackage.DATA_SOURCE__CONNECTION_URL:
        setConnectionUrl((String)newValue);
        return;
      case ApusicPackage.DATA_SOURCE__DRIVER_CLASS_PATH:
        setDriverClassPath((String)newValue);
        return;
      case ApusicPackage.DATA_SOURCE__HOST:
        setHost((String)newValue);
        return;
      case ApusicPackage.DATA_SOURCE__PORT:
        setPort(((Integer)newValue).intValue());
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ApusicPackage.DATA_SOURCE__NAME:
        setName(NAME_EDEFAULT);
        return;
      case ApusicPackage.DATA_SOURCE__CONNECTION_URL:
        setConnectionUrl(CONNECTION_URL_EDEFAULT);
        return;
      case ApusicPackage.DATA_SOURCE__DRIVER_CLASS_PATH:
        setDriverClassPath(DRIVER_CLASS_PATH_EDEFAULT);
        return;
      case ApusicPackage.DATA_SOURCE__HOST:
        setHost(HOST_EDEFAULT);
        return;
      case ApusicPackage.DATA_SOURCE__PORT:
        setPort(PORT_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ApusicPackage.DATA_SOURCE__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case ApusicPackage.DATA_SOURCE__CONNECTION_URL:
        return CONNECTION_URL_EDEFAULT == null ? connectionUrl != null : !CONNECTION_URL_EDEFAULT.equals(connectionUrl);
      case ApusicPackage.DATA_SOURCE__DRIVER_CLASS_PATH:
        return DRIVER_CLASS_PATH_EDEFAULT == null ? driverClassPath != null : !DRIVER_CLASS_PATH_EDEFAULT.equals(driverClassPath);
      case ApusicPackage.DATA_SOURCE__HOST:
        return HOST_EDEFAULT == null ? host != null : !HOST_EDEFAULT.equals(host);
      case ApusicPackage.DATA_SOURCE__PORT:
        return port != PORT_EDEFAULT;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(", connectionUrl: ");
    result.append(connectionUrl);
    result.append(", driverClassPath: ");
    result.append(driverClassPath);
    result.append(", host: ");
    result.append(host);
    result.append(", port: ");
    result.append(port);
    result.append(')');
    return result.toString();
  }

} //DataSourceImpl
